<?php

namespace App\Http\Controllers;

use App\Models\ArticleView;
use Illuminate\Http\Request;

class ArticleController extends BaseController
{
    public function list(Request $request){
        $page = $request->input('page');
        $type = $request->input('type');
        $perPage = $request->input('per_page', 10);

        $db = ArticleView::query();
        if($type){
            $db->where(['type'=>$type]);
        }

        $lists =$db ->where(['status'=>2])
            ->paginate($perPage, ['*'], 'page', $page);

        foreach ($lists as $data) {
            $data->userInfo;
            $data->albumInfo;
            $data->groupInfo;
        }

        return $lists;
    }
}
